<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="java.util.ArrayList" %>
<%@page import="DBFunction.fSetAllOffline"%><html xmlns="http://www.w3.org/1999/xhtml">
<%
if(session.getAttribute("adminFirstName")==null)response.sendRedirect("index.jsp");; 

%>
    <head>
    	<title>Buddy Tracking Management Server</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link rel="stylesheet" media="all" type="text/css" href="Css/Main.css"/>
		<link rel="stylesheet" href="jquery/themes/buddytracking/jquery.ui.all.css"> 
		<script src="jquery/jquery-1.5.1.js"></script> 
		<script src="js/jquery.validate.min.js"></script> 
		<script src="jquery/ui/jquery.ui.core.js"></script> 
		<script src="jquery/ui/jquery.ui.position.js"></script>
		<script src="jquery/ui/jquery.ui.widget.js"></script> 
		<script src="jquery/ui/jquery.ui.mouse.js"></script>
		<script src="jquery/ui/jquery.ui.draggable.js"></script>
		<script src="jquery/ui/jqwuery.ui.resizable.js"></script>
		<script src="jquery/ui/jquery.ui.button.js"></script>
		<script src="jquery/ui/jquery.ui.accordion.js"></script>
		<script src="jquery/ui/jquery.ui.dialog.js"></script>
		<script> 
		$(document).ready(function() {
			$("#addAdminForm").validate();
		});
		
		$(function() {
			var selectedAll = false;
			$("button, input:submit, .submit, #logout,#managepage,.addAdminButton,.deleteAdminButton", "#managementbody" ).button();
			$('#accordion').accordion({
			autoHeight: false,
			navigation: true,
			collapsible: true,
			header: "h3"
			});

			$("#addAdminDialog").dialog({
				autoOpen:false,
				modal:true,
				draggable:true,
				resizable: false,
				closeOnEscape:true,
				autoHeight : true,
				title :'Add Administrator Account',
				buttons: { "Ok": function() { var form=$("#addAdminForm").validate();form.resetForm();$("#addAdminForm").submit(); } ,
				 "Cancel": function() { $(this).dialog("close"); $("#addAdminForm")[0].reset();} }
			});
			$(".addAdminButton").click(function(){
				$("#addAdminDialog").dialog("open");
			});
			$(".deleteAdminButton").click(function(){
				$("#deleteAdminForm").submit();
			});
			$("#logout").click(function() {$("#logoutform").submit(); });
		});
		</script>
    </head>
    <body >
    	<div id="managementbody">
    	<form id="logoutform" method="GET" action="ServerAdminLogout"></form>
    		<div id="banner"><div id="welcomelabel">Welcome ${adminLastName}&nbsp;${adminFirstName}&nbsp;&nbsp;&nbsp;</div><div id="navigation"><a id="managepage" name="managepage" href="managementpage.jsp" >Management</a><a id="logout" name="logout" >Sign Out</a></div></div>
			<div id="configpage">
				<form method="GET" id="deleteAdminForm" action="ServerAdminManager">
				<input type="hidden" name="action" class="action" value="delete"/>
				<table >
					<tr align="center">
						<td></td>
						<td><a class="addAdminButton">Add New Account</a></td>
						<td><a class="deleteAdminButton">Delete Selected</a></td>
					</tr>
					<tr align="center">
						<td></td>
						<td><a href="#" class="adminInfo" id="adminId">Admin</a></td>
						<td>Administrator</td>
					</tr>
					<c:forEach items="${Admin}" var="currentAdmin">
					<tr align="center">
						<td><input name="adminSelect" class ="adminSelect" type="checkbox" value="${currentAdmin.id }"></td>
						<td><a href="#" class="adminInfo" id="${currentAdmin.id }">${currentAdmin.account}</a></td>
						<td>${currentAdmin.firstName}&nbsp;${currentAdmin.lastName}</td>
						
					</tr>
					</c:forEach>
				</table>
				</form>
			</div>
		</div>
		<div id="addAdminDialog" >
			<form method="GET" id="addAdminForm" action="ServerAdminManager">
			<input type="hidden" name="action" class="action" value="add"/>
			<table id="">
				<tr>
					<td>Account</td>
				</tr>
				<tr>
					<td><input class="required NumbersOnly" minlength="2" maxlength="10" type="text" name="account" id="account"/></td>
				</tr>
				<tr>
					<td>Passwords</td>
				</tr>
				<tr>
					<td><input class="required" minlength="5" maxlength="30" type="password" name="passwords" id="Passwords"/></td>
				</tr>
				<tr>
					<td>Retype Passwords</td>
				</tr>
				<tr>
					<td><input class="required" minlength="5" maxlength="30" equalTo="#Passwords" type="password" name="rePasswords"id="RetypePasswords"/></td>
				</tr>
				<tr>
					<td>First Name</td>
				</tr>
				<tr>
					<td><input class="required" minlength="2" maxlength="40"type="text" name="firstName" id="FirstName"/></td>
				</tr>
				<tr>
					<td>Last Name</td>
				</tr>
				<tr>
					<td><input class="required" minlength="2" maxlength="40" type="text" name="lastName" id="LastName"/></td>
				</tr>	
			</table>
			</form>
		</div>
    </body>
</html>
